package cn.online.taxi.valuation.service.impl;

import cn.online.taxi.common.utils.LatNLongDistance;
import cn.online.taxi.manager.dto.front.Order;
import cn.online.taxi.valuation.service.ValuationService;
import com.alibaba.dubbo.config.annotation.Service;

import java.time.Clock;
import java.time.LocalTime;

/**
 * @Author BinBini
 * @Date 2021/4/27 17:20
 * @Version 1.0
 */
@Service
public class ValuationServiceImpl implements ValuationService {

    @Override
    public Double calcForecastPrice(double startLongitude, double startLatitude, double targetLongitude, double targetLatitude) {
        Double result = 1.0;
        double distance = LatNLongDistance.distanceByLongNLat(startLongitude, startLatitude, targetLongitude, targetLatitude);
        LocalTime time = LocalTime.now();
        int hour = time.getHour();
        if(hour >= 6 && hour <= 21) {
            result += 10;
        } else {
            result += 13;
        }
        if(distance > 2000) {
            result += (distance / 1000 - 2) * 2.6;
        }
        if(distance > 10000) {
            result += (distance / 1000 - 10) * 3.9;
        }
        return result;
    }

}
